
import type { App } from "vue";
import loading from "@/static/images/loading.gif";

// 自定义图片的懒加载指令 v-lazy
export default (app: App) => {
    app.directive("lazy", {
        beforeMount(el) {
            if (!el.src) {
                el.src = loading;//懒加载的图片
            }
        },
        // dom加载之后的钩子
        mounted(el, building) {
            el.src = building.value;//获取的是新获取的图片地址
        }
    })
}